package com.sinsoft.monitorDemo.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sinosoft.framework.core.common.utils.ajax.ResponseData;
import com.sinsoft.monitorDemo.dao.TomcatInfoDao;
import com.sinsoft.monitorDemo.entity.TomcatInfo;

@Controller
@RequestMapping("/TomcatInfo")
public class TomcatInfoController {
	
	/**
	 * 得到最近一段时间的的TOmcat信息
	 * @return
	 */
	@RequestMapping(value = "/getTomcatInfoList", method = RequestMethod.POST)
	@ResponseBody
	public ResponseData getTomcatInfoList(HttpServletRequest request){
		TomcatInfoDao dao = new TomcatInfoDao();
		String ip = request.getParameter("ip");
		String code = request.getParameter("code");
		List<TomcatInfo> tomcatInfo = dao.getTomcatInfoList(ip,code);
		ResponseData responseData = new ResponseData(true, tomcatInfo);
		return responseData;	
	}
	
	/**
	 * 得到最新的Tomcat信息
	 * @return
	 */
	@RequestMapping(value = "/getNewTomcatInfo", method = RequestMethod.POST)
	@ResponseBody
	public ResponseData getNewTomcatInfo(HttpServletRequest request){
		TomcatInfoDao dao = new TomcatInfoDao();
		String ip = request.getParameter("ip");
		String code = request.getParameter("code");
		TomcatInfo tomcatInfo = dao.getNewTomcatInfo(ip,code);
		ResponseData responseData = new ResponseData(true, tomcatInfo);
		return responseData;	
	}
}
